package ge.hr.gg.levan;

import android.os.Bundle;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class MainActivity extends Activity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		Button qartuli = (Button) findViewById(R.id.qartuli);
		Button inglisuri = (Button) findViewById(R.id.inglisuri);
		qartuli.setOnClickListener(onQartuli);
		inglisuri.setOnClickListener(onInglisuri);
		ListView latestVaccancies = (ListView) findViewById(R.id.latestVaccancies);
		String[] values = new String[] { "Populi - Gamyidveli",
				"Magti - Operatori", "Goodwill - Sacyobis mmartveli",
				"Sheraton - Momsaxure personali", "Orient Logic - Sysadmini",
				"Meria - Mexandzre","Populi - Gamyidveli",
				"Magti - Operatori", "Goodwill - Sacyobis mmartveli",
				"Sheraton - Momsaxure personali", "Orient Logic - Sysadmini",
				"Meria - Mexandzre" };
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, values);
		latestVaccancies.setAdapter(adapter);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

	private View.OnClickListener onQartuli = new View.OnClickListener() {
		public void onClick(View v) {
			// TextView hello = (TextView)findViewById(R.id.helloText);
			// hello.setText("გამარჯობა");
			// scroll.setVisibility(View.INVISIBLE);
		}
	};
	private View.OnClickListener onInglisuri = new View.OnClickListener() {
		public void onClick(View v) {
			// TextView hello = (TextView)findViewById(R.id.helloText);
			// hello.setText("hello");
			// scroll.setVisibility(View.VISIBLE);
		}
	};

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle item selection
		switch (item.getItemId()) {
		case R.id.menu_settings:
			Intent settings = new Intent(this, Settings.class);
			this.startActivity(settings);
			return true;
		case R.id.menu_about:
			// custom dialog
			final Dialog dialog = new Dialog(this);
			dialog.setContentView(R.layout.about);
			dialog.setTitle("HR.ge");
			ImageView image = (ImageView) dialog.findViewById(R.id.image);
			image.setImageResource(R.drawable.ic_launcher);

			Button dialogButton = (Button) dialog
					.findViewById(R.id.dialogButtonOK);
			// if button is clicked, close the custom dialog
			dialogButton.setOnClickListener(new OnClickListener() {
				public void onClick(View v) {
					dialog.dismiss();
				}
			});

			dialog.show();
			return true;
		default:
			return super.onOptionsItemSelected(item);
		}
	}
}
